{extend name="public/base" /}
{block name="title"}用户组管理{/block}
{block name="css"}{/block}
{block name="main"}

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>用户分组 </h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                        <i class="fa fa-wrench"></i>
                    </a>
                    <ul class="dropdown-menu dropdown-user">
                        <li><a href="javascript:;" onclick="add()">添加分组</a></li>
                    </ul>
                    <a class="close-link">
                        <i class="fa fa-times"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content" style="padding:10px">
                <a href="javascript:;" onclick="add()" class="btn btn-success">添加分组</a>
                <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover table-condensed">
                        <tr>
                            <th>用户组名</th>
                            <th>操作</th>
                        </tr>
                        {foreach name="data" item="v"}
                        <tr>
                            <td>{$v['title']}</td>
                            <td>
                                <a href="javascript:;" ruleId="{$v['id']}" ruleTitle="{$v['title']}" onclick="edit(this)">修改</a> |
                                <a class="ajax-btn-warning" data-action="{:url('Rule/deleteGroup',['id'=>$v['id']])}" data-title="提示" data-text="确认要删除吗?">删除</a> |
                                <a href="{:url('Rule/ruleGroup',['id'=>$v['id']])}">分配权限</a> |
                                <a href="{:url('Rule/checkUser',['role_id'=>$v['id']])}">成员管理</a>
                            </td>
                        </tr>
                        {/foreach}
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>


<!-- 添加菜单模态框开始 -->
<div class="modal fade" id="bjy-add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
     <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
          &times;
        </button>
        <h4 class="modal-title" id="myModalLabel">
          添加用户组
        </h4>
      </div>
      <div class="modal-body">
        <form id="bjy-form" class="form-horizontal ajax-form" action="{:url('Rule/addGroup')}" method="post">
          <div class="form-group">
            <label class="col-lg-2 control-label">用户组名:</label>
            <div class="col-lg-10"><input type="text" name="title" placeholder="用户组名" class="form-control"> <span class="help-block m-b-none"></span>
            </div>
          </div>
          <div class="form-group">
            <div class="col-lg-offset-2 col-lg-10">
              <button class="btn btn-sm btn-white" type="submit">添加</button>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
<!-- 添加菜单模态框结束 -->

<!-- 修改菜单模态框开始 -->
<div class="modal fade" id="bjy-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
     <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
          &times;
        </button>
        <h4 class="modal-title" id="myModalLabel">
          修改规则
        </h4>
      </div>
      <div class="modal-body">
        <form id="bjy-form" class="form-horizontal ajax-form" action="{:url('Rule/editGroup')}" method="post">
          <input type="hidden" name="id">
          <div class="form-group">
            <label class="col-lg-2 control-label">用户组名:</label>
            <div class="col-lg-10"><input type="text" name="title" placeholder="用户组名" class="form-control"> <span class="help-block m-b-none"></span>
            </div>
          </div>
          <div class="form-group">
            <div class="col-lg-offset-2 col-lg-10">
              <button class="btn btn-sm btn-white" type="submit">添加</button>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
{/block}
{block name="js"}
<script>
// 添加菜单
function add(){
    $("input[name='title']").val('');
    $('#bjy-add').modal('show');
}

// 修改菜单
function edit(obj){
    var ruleId=$(obj).attr('ruleId');
    var ruletitle=$(obj).attr('ruletitle');
    $("input[name='id']").val(ruleId);
    $("input[name='title']").val(ruletitle);
    $('#bjy-edit').modal('show');
}
</script>
{/block}